<template>
  <div class="view-container">

    <table-search-view :search-items="searchItems" :table-items="tableItems" :search-function="search">
      <template slot="action" slot-scope="scope">
        <action-info :scope="scope"></action-info>
      </template>
    </table-search-view>

  </div>
</template>

<script>
  import TableSearchView from '@/components/TableSearchView';

  import actionOrderInfo from './components/actionOrderInfo.vue';
  import {getOrderExpireList} from '@/api/order';

  export default {
    name: 'orderReturnExpire', /*到期待还*/
    components: {
      'table-search-view':TableSearchView,
      'action-info':actionOrderInfo,
    },
    data ()
    {
      return {
        searchItems: [
          {
            label: '商品名称',
            type: 'autocomplete',
            placeholder:'请输入商品名称',
            model:'goodName',
          },
          {
            label: '到期时间',
            type: 'datetimerange',
            placeholder:'请选择到期时间',
            model:'timeRange',
          },
          {
            label: '订单编号',
            type: 'input',
            placeholder:'请输入订单编号',
            model:'orderId',
          },
          {
            label: '下单用户',
            type: 'input',
            placeholder:'请输入下单用户',
            model:'userName',
          }
        ],
        tableItems:[
          {
            label:'订单编号',
            prop:'orderNumber',
            width:'180px;',
          },
          {
            label:'商品名称',
            prop:'goodsName',
            width:'180px;',
            sortable:true,
          },
          {
            label:'下单用户',
            prop:'userName',
            width:'180px;',
            sortable:true,
          },
          {
            label:'到期时间',
            prop:'leaseExpireTime',
            width:'160px;',
            formatter:'parseTime',
          },
          {
            label:'结清时间',
            prop:'clearanceTime',
            width:'160px;',
            formatter:'parseTime',
          },
          {
            label:'订单状态',
            prop:'stateStr',
            width:'100px;',
            sortable:true,
          },
          {
            type:'scope',
            label:'操作',
            slot:'action',
          },

        ],
      }
    },
    methods: {
      search(data)
      {
         return getOrderExpireList(data);
        /* return new Promise(resolve => {
          let resp = {data:{total:10, list:[
            {
              "id": 95082,
              "goodsName": "EY0PDSRoso",
              "userName": "MOoT4WjPVf",
              "leaseExpireTime": 1505973251476,
              "clearanceTime": 1505972905218,
              "state": "9eMccqeeHv",
              "stateStr": "到期待还"
            },
            {
              "id": 95709,
              "goodsName": "W9CqFyTnL0",
              "userName": "8QMl1eetTe",
              "leaseExpireTime": 1505974718486,
              "clearanceTime": 1505973093007,
              "state": "7S1Rjj05GF",
              "stateStr": "到期待还"
            },
            {
              "id": 95879,
              "goodsName": "ZYk2LhOvzR",
              "userName": "7aKZnj5Yta",
              "leaseExpireTime": 1505973391826,
              "clearanceTime": 1505973142944,
              "state": "KDVp9rfJ2e",
              "stateStr": "到期待还"
            }
          ]}};

          resolve(resp);
        });*/
      }
    }
  }
</script>
